<template>
  <div class="container mainCon">
    <el-tabs
      v-model="activeName"
      type="card"
      @tab-click="handleClick"
      class="commonTab"
    >
      <el-tab-pane label="全部任务" name="first">
        <allTaskList v-if="isShowFirst"></allTaskList>
      </el-tab-pane>
      <el-tab-pane label="我创建的任务" name="second">
        <myTaskList v-if="isShowSecond"></myTaskList>
      </el-tab-pane>
      <el-tab-pane label="指派给我的任务" name="third">
        <assignedTaskList v-if="isShowThird"></assignedTaskList>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import allTaskList from '@/components/patrolTask/allTaskList'
import myTaskList from '@/components/patrolTask/myTaskList'
import assignedTaskList from '@/components/patrolTask/assignedTaskList'

export default {
  name: 'patrolTaskList',
  components: {
    allTaskList,
    myTaskList,
    assignedTaskList,
  },
  data() {
    return {
      activeName: 'first',
      isShowFirst: true,
      isShowSecond: false,
      isShowThird: false,
    }
  },
  created() {
    if (this.$route.query.activeName) {
      this.activeName = this.$route.query.activeName
      this.isShowSecond = true
    }
  },
  methods: {
    //tabs栏切换
    handleClick(tab, event) {
      if (tab.label == '全部任务') {
        this.isShowFirst = true
      } else if (tab.label == '我创建的任务') {
        this.isShowSecond = true
      } else if (tab.label == '指派给我的任务') {
        this.isShowThird = true
      }
    },
  },
}
</script>

<style scoped lang="less">
.mainCon {
  top: 130px;
  padding: 0;
}
</style>
